home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Telephone Manager / Stiletto Sources / ModuleSources / SetHooksw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-03  |  3.3 KB  |  123 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Module Name:    SetHooksw                                                                    */
  4. /*                                                                                                */
  5. /*    File Name:        SetHooksw.c                                                                    */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1991-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1991-08-14    Chris Halim            Original version                                        */
  15. /*        1995-06-26    Jaakko Railo        Version 2.0                                                */
  16. /*                                                                                                */
  17. /************************************************************************************************/
  18.  
  19. /****************************************** DESCRIPTION ******************************************
  20.  
  21. *************************************************************************************************/
  22.  
  23. /******************************************** HEADERS *******************************************/
  24.  
  25. #include "TextUtils.h"
  26.  
  27. #ifndef __TELEPHONES__
  28. #include "Telephones.h"
  29. #endif
  30.  
  31. #include "TestModule.h"
  32.  
  33. /****************************************** DEFINITIONS *****************************************/
  34.  
  35. #define    rDisplayHookswDLOG    10000
  36. #define    kNumber                3
  37. #define    kOnHookItem            1
  38. #define    kOffHookItem        5
  39.  
  40. /****************************************** PROTOTYPES ******************************************/
  41.  
  42. short    DisplayHooksw (short * htype);
  43. void     DoTest (CHRSPtr paramPtr);
  44.  
  45. /************************************************************************************************/
  46. /************************************************************************************************/
  47.  
  48.  
  49. pascal short TestModule (CHRSPtr paramPtr)
  50. {
  51.     short    returnValue = noErr;
  52.     
  53.     if (paramPtr->version <= kTestModuleVersion) {
  54.         
  55.         DoTest (paramPtr);
  56.         
  57.     }
  58.     else
  59.         returnValue = kWrongVersion;
  60.         
  61.     return (returnValue);
  62. }
  63.  
  64.  
  65. short    DisplayHooksw (short * number)
  66. {
  67.     short        itemKind;
  68.     Handle        itemHand;
  69.     Rect        itemRect;
  70.     short        itemHit;
  71.     DialogPtr    theDialog;
  72.     Str255        itemStr;
  73.     long        tlong;
  74.     
  75.     if ((theDialog = GetNewDialog (rDisplayHookswDLOG, nil, (WindowPtr)(-1L))) != nil) {
  76.         GetDItem (theDialog, kNumber, &itemKind, &itemHand, &itemRect);
  77.         SelIText (theDialog, kNumber, 0, 32767);
  78.         
  79.         ShowWindow (theDialog);
  80.         
  81.         ModalDialog (nil, &itemHit);
  82.         
  83.         if ((itemHit == kOnHookItem) || (itemHit == kOffHookItem)) {
  84.             GetDItem (theDialog, kNumber, &itemKind, &itemHand, &itemRect);
  85.             GetIText (itemHand, itemStr);
  86.             StringToNum (itemStr, &tlong);
  87.             *number = tlong;
  88.         }
  89.         
  90.         DisposeDialog (theDialog);
  91.     }
  92.     else
  93.         itemHit = -1;
  94.     
  95.     return (itemHit);
  96. }
  97.  
  98.  
  99. void DoTest (CHRSPtr paramPtr)
  100. {
  101.     TELHandle    termHand = GetCurrentTELHandle (paramPtr);
  102.     short        itemHit, htype;
  103.     OSErr        errCode;
  104.     Boolean        onHook;
  105.     
  106.     itemHit = DisplayHooksw (&htype);
  107.     if ((itemHit == kOnHookItem) || (itemHit == kOffHookItem)) {
  108.         
  109.         onHook = (itemHit == kOnHookItem)?telDeviceOnHook:telDeviceOffHook;
  110.         
  111.         if ((errCode = TELSetHooksw (termHand, htype, onHook)) == noErr)
  112.             Print (paramPtr, "TELSetHooksw --> hookState = %s", 
  113.                     ((onHook==telDeviceOnHook)?"telDeviceOnHook":"telDeviceOffHook"));
  114.         else
  115.             Print (paramPtr, "### TELSetHooksw failed : %d", errCode);
  116.     }
  117.     else
  118.         if (itemHit == -1)
  119.             Print (paramPtr, "### Unable to get a DLOG resource");
  120. }
  121.  
  122.  
  123.